package com.zx.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class OutputUtil {
	/**
	 * @Title: 将文本输入到文件中(覆盖文件)
	 * @param text
	 * @param filePath
	 * @date: 2018年8月4日下午6:08:32
	 */
	public static void outputTextToFile(String text, String filePath) {
		File file = new File(filePath);
		if(file.exists() && file.isDirectory()) {
			throw new RuntimeException(filePath + "是一个文件夹，不能操作");
		}
		
		try(
				FileWriter fileWriter = new FileWriter(file);
				BufferedWriter bw = new BufferedWriter(fileWriter);
				){
			bw.write(text);			
		} catch (IOException e) {
			e.printStackTrace();
		} 
		
	}
}
